// 生成随机密钥的函数
function generateSecret(length = 32) {
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+';
  let result = '';
  for (let i = 0; i < length; i++) {
    result += chars.charAt(Math.floor(Math.random() * chars.length));
  }
  return result;
}

// 如果没有设置环境变量，使用生成的随机密钥
const accessSecret = process.env.ACCESS_TOKEN_SECRET || generateSecret();
const refreshSecret = process.env.REFRESH_TOKEN_SECRET || generateSecret();

module.exports = {
    ACCESS_TOKEN_SECRET: accessSecret,
    REFRESH_TOKEN_SECRET: refreshSecret,
    ACCESS_TOKEN_EXPIRES_IN: '15m', // 访问令牌15分钟
    REFRESH_TOKEN_EXPIRES_IN: '7d'  // 刷新令牌7天
  }